clc;clear;
c = 299792458;
sampleperchip  12.5/2.046;
% [1:5,9,10,12,14,19,20,25,26,29,30] 采集器
% [3,6,8,13,16,19,20] 对天采集
% [1,2,3,4,5,6,8,10,22,23,24,28,29,30]采集器加LNA
for prn =  [1,2,3,4,5,6,8,10,22,23,24,28,29,30]

    filepath = ['dir_trackingresult',num2str(prn)];
    load([filepath,'/trackingResults0.5.mat'])
    codephase1 = trackResults.remCodePhase;
    absoluteSample1 =  trackResults.absoluteSample;

    load([filepath,'/trackingResults0.45.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_9 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    load([filepath,'/trackingResults0.4.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_8 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;
    
    load([filepath,'/trackingResults0.35.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_7 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    load([filepath,'/trackingResults0.3.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_6 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    load([filepath,'/trackingResults0.25.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_5 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    load([filepath,'/trackingResults0.2.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_4 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    load([filepath,'/trackingResults0.15.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_3 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    load([filepath,'/trackingResults0.1.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_2 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;
    
    load([filepath,'/trackingResults0.05.mat'])
    phase_co =  trackResults.absoluteSample-absoluteSample1;
    codephase0_1 = (trackResults.remCodePhase-codephase1)-phase_co/sampleperchip/4;

    codephase_cha(1,:) = codephase0_1 ;
    codephase_cha(2,:) = codephase0_2 ;
    codephase_cha(3,:) = codephase0_3 ;
    codephase_cha(4,:) = codephase0_4 ;
    codephase_cha(5,:) = codephase0_5 ;
    codephase_cha(6,:) = codephase0_6 ;
    codephase_cha(7,:) = codephase0_7 ;
    codephase_cha(8,:) = codephase0_8 ;
    codephase_cha(9,:) = codephase0_9 ;
    codephase_cha(10,:) = codephase1 - codephase1;
    
    
    scb_line = mean(codephase_cha(:,6000:end),2);
    x_index = 0.1:0.1:1;
    % if prn == 4
    %     plot(x_index,-scb_line/2.046e6*c,'-o');
    % else
    %     plot(x_index,scb_line/2.046e6*c,'-o');
    % end
    plot(x_index,scb_line/2.046e6*c,'-o');
    xlabel("相关间隔/chips");
    ylabel("过零点偏差/m");
    title("SCB");
    grid on
    hold on
end

% legend("prn=1","prn=2","prn=3","prn=4","prn=5","prn=9","prn=10", ...
%     "prn=12","prn=14","prn=19","prn=20","prn=25","prn=26","prn=29","prn=30")

% legend("prn=2","prn=3","prn=5")
% legend("prn=1","prn=4","prn=9","prn=10", ...
%      "prn=12","prn=14","prn=19","prn=20","prn=25","prn=26","prn=29","prn=30")

% legend("prn=3","prn=6","prn=8","prn=13","prn=16","prn=19","prn=20")
legend("prn=1","prn=2","prn=3","prn=4","prn=5","prn=6","prn=8","prn=10", ...
    "prn=22","prn=23","prn=24","prn=28","prn=29","prn=30")
